package com.s3.khospitalds.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.s3.khospitalds.entity.Doctor;
import com.s3.khospitalds.entity.DoctorResignInfo;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @Author: 想要告诉你
 * @CreateTime: 2025/2/19 10:15
 * @Description:
 * @Version: 1.0
 */

@Mapper
@Repository
public interface DoctorMapper extends BaseMapper<Doctor>{
    @Select("SELECT * FROM doctor")
    public List<Doctor> getDoctorResignInfo();
    @Insert("INSERT INTO doctor (`name`, sex, `date`, degree, major, profession, office, officeId, isexpert) VALUES\n" +
            "(#{name} , #{sex} , #{date}, #{degree} , #{major} , #{profession} , #{office} , #{officeId} , 1 )")
    public int insertDoctor(Doctor doctor);

    @Update("UPDATE doctor SET `name` = #{name}, sex = #{sex}, `date` = #{date}, degree = #{degree}, major = #{major}, profession = #{profession}, office = #{office}, officeId = #{officeId}, isexpert = #{isexpert} WHERE id = #{id}")
    boolean updateDoctor(Doctor doctor);

    @Delete("DELETE FROM doctor WHERE id = #{id}")
    boolean deleteDoctor(int id);

    @Update("UPDATE doctor SET isexpert = 2, leave_date = NOW(), reason = #{reason}, processor = #{processor} WHERE id = #{id}")
    boolean updateDoctorResign(DoctorResignInfo doctorResignInfo);
}
